import { Context, Next } from "koa"
import { IUserVo } from "../data/User"
import RandomUtil from "../utils/RandomUtil"

export default class UserController {
  /**
   * 游客登录
   * @param ctx 
   * @param next 
   */
  static async loginByGuest(ctx: Context, next: Next) {
    const randomVal = RandomUtil.getRangeInt(10000, 99999)
    const user: IUserVo = {
      id: `${Date.now()}-${randomVal}`,
      name: "guest_" + randomVal,
      balance: 1000
    }
    // 返回请求结果
    ctx.succ({
      data: {
        user
      }
    })
  }
}